# -*- encoding: utf-8 -*-
"""
    Created by Rachel on 2025/03/06
"""
import os
import pkgutil

from flask import Blueprint, Flask


class RegisterBlueprint:
    public = Blueprint("public", __name__, url_prefix="/public")

    def __init__(self, app: Flask):
        self.app = app
        self.init_api()

    def init_api(self):

        pkg_path = os.path.dirname(__file__)
        pkg_name = os.path.basename(pkg_path)
        for _, file, is_pkg in pkgutil.walk_packages([pkg_path], "applications." + pkg_name + "."):
            if not is_pkg:
                __import__(file)

        self.register_public_blueprint()

    def register_public_blueprint(self):
        """注册平台公共蓝图"""
        self.app.register_blueprint(self.public)
